package com.example.win.android_banduyujia.peopleactivity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.win.android_banduyujia.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Win on 2015/9/4.
 */
public class GridTextAdapter extends BaseAdapter {

    private List<String>  child_text_array = new ArrayList<String>();
    private Context   mContext;

    public GridTextAdapter(Context context, List<String> child_text_array) {
        this.mContext = context;
        this.child_text_array = child_text_array;
    }

    @Override
    public int getCount() {
        return child_text_array.size();
    }

    @Override
    public Object getItem(int position) {
        return child_text_array.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder  viewHolder=null;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.scope_grid_view_type,null);
            viewHolder = new ViewHolder();
            viewHolder.mTvType = (TextView) convertView.findViewById(R.id.scope_item_goods_type);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mTvType.setText(child_text_array.get(position));
        return convertView;
    }

    public class ViewHolder{
        TextView  mTvType;
    }
}
